﻿@using Seal.Model
@{
    Report report = Model;
    ReportView view = report.CurrentView;
    int index = 0;
    var views = view.Views.OrderBy(i => i.SortOrder).ToList();
    var gridLayout = report.PrintLayout ? view.GetValue("grid_layout_print") : view.GetValue("grid_layout");
    if (string.IsNullOrWhiteSpace(gridLayout))
    {
        gridLayout = view.GetValue("grid_layout");
    }
}
<div id='@("container_" + view.IdSuffix)' class="container@(report.ExecutionView.GetBoolValue("container_fluid") ? "-fluid" : "")">
    @foreach (string row in view.GetGridLayoutRows(gridLayout.Trim()))
    {
        <div class="row">
            @foreach (string col in view.GetGridLayoutColumns(row))
            {
                <div class="@view.GetGridLayoutColumnClass(col) @view.GetValue("grid_cell_class")" @Raw(view.AddAttribute("style", "grid_cell_css"))>
                    @if (index < view.Views.Count && view.IsGridLayoutColumnForModel(col))
                    {
                        @Raw(views[index++].Parse())
                    }
                </div>
            }
        </div>
    }
    @while (index < views.Count)
    {
        //Remaining views
        <div class="row">
            @Raw(views[index++].Parse())
        </div>
    }
</div>